package com.smbms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.smbms.mapper.ProviderMapper;
import com.smbms.pojo.Provider;
import com.smbms.service.ProviderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ProviderServiceImpl implements ProviderService {

    @Resource
    private ProviderMapper providerMapper;

    @Override
    public boolean add(Provider provider) {
        return providerMapper.insert(provider)>0;
    }

    @Override
    public List<Provider> getProviderList(String queryProName, String queryProCode) {
        return providerMapper.getProviderList(queryProName,queryProCode);
    }

    @Override
    public List<Provider> getProvider() {
        QueryWrapper<Provider> queryWrapper=new QueryWrapper<>();
        queryWrapper.select("id","proName");
        return providerMapper.selectList(queryWrapper);
    }

    @Override
    public int deleteProviderById(String delId) {
        return providerMapper.deleteById(delId);
    }

    @Override
    public Provider getProviderById(String id) {
        return providerMapper.selectById(id);
    }

    @Override
    public boolean modify(Provider provider) {
        QueryWrapper<Provider> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("id", provider.getId());
        return providerMapper.update(provider,queryWrapper)>0;
    }
}
